function isString(value) {
  return typeof value === "string" || value instanceof String;
}

function notEmpty(value) {
  if (Array.isArray(value)) {
    return value.length > 0;
  }
  if (typeof value === "object" && value !== null) {
    return Object.keys(value).length > 0;
  }
  return isString(value) && value.trim().length > 0;
}

function stringify(value) {
  return Object.entries(value)
    .map(([key, value]) => {
      if (typeof value === "object") {
        value = stringify(value);
      }
      return `${key}=${value}`;
    })
    .join("&");
}

export { isString, notEmpty, stringify };
